<include file="Public:header" />
<link href="__PUBLIC__/css/litebox.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__PUBLIC__/style/js/TableFreeze.js"></script>
<script src="__PUBLIC__/js/mxcrm_more.js" type="text/javascript"></script>
<style>
body{
	overflow-y: hidden;
}
.option{padding-left:-30px;}
</style>
<script>
$(function(){
	var scroll_width = 5;
	$("#table_div").height(window.innerHeight-$("#table_div").offset().top-$("#tfoot_div").height()-parseInt($("#table_container").css("padding-bottom").replace("px",""))-10);
	$(window).resize(function(){
		$("#table_div").height(window.innerHeight-$("#table_div").offset().top-$("#tfoot_div").height()-parseInt($("#table_container").css("padding-bottom").replace("px",""))-10);
		$("#oDivL_tab_Test3").height($("#table_div").height()-scroll_width-1).width($("#oTableLH_tab_Test3").width());
		$("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width()-scroll_width);
	})
	if ("{$Think.get.by}") {
		$("#filter_ul").prev().html($("#filter_ul>li>a.active").text()+'<span class="fa fa-angle-down small_fa"></span>');
	}
	$("#tab_Test3").FrozenTable(1,0,3);
	$("#oDivL_tab_Test3").height($("#table_div").height()-scroll_width).width($("#oTableLH_tab_Test3").width());
	$("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width()-scroll_width);
	//$("#oDivH_tab_Test3").css('top','-7px');
})
</script>
<div class="wrapper wrapper-content ">
	<include file="Public:alert" />
    <div class="row">
        <div class="col-md-12">
            <div class="ibox float-e-margins">
				<div class="title-bar" style="position: relative;z-index: 99;">
					<div class="row  clearfix" id="title-hide" style="display:none;">
						<ul class="breadcrum pull-left">
							<li>已选中&nbsp;<span id="icheck_num"></span>&nbsp;项</li>
							<li class="single_btn"><a href="javascript:void(0)" id="edit_contract"><i class="fa fa-pencil"></i>&nbsp;编辑</a></li>
							<li><a id="delete" href="javascript:void(0)"><i class="fa fa-times"></i>&nbsp;删除</a></li>
							<li class="last_li"><big><a class="fa fa-times pull-right" id="back-show"></a></big></li>
						</ul>
					</div>
					<div class="row " id="title-show">
						<ul class="nav pull-left" style="margin:2px 0 0 15px;">
							<a class="btn btn-primary btn-sm" href="{:U('announcement/add')}"><i class="fa fa-plus"></i>&nbsp; {:L('ADD THE ANNOUNCEMENT')}</a>
						</ul>
						<form class="form-inline" id="" action="" method="get">
						<ul class="breadcrum pull-right" style="margin-bottom: 0px">
							<li>
								搜索：
								<div class="input-group">
									<input type="hidden" name="m" value="announcement"/>
									<input type="hidden" name="a" value="index"/>
									<input type="hidden" name="condition" value="contains"/>
									<input type="hidden" name="field" value="title"/>
									<input id="short_search" type="text" style="width:160px;" placeholder="请输入公告标题" onkeydown='if(event.keyCode==13) {$("#short_search_btn").trigger("click");return false;}' class="form-control input-sm" name="search" <if condition = "$_GET['field'] eq 'name'">value="{$_GET['search']}"</if>/>
									<span class="input-group-btn">
										<button class="btn btn-default btn-search" id="short_search_btn" type="submit"><i class="fa fa-search"></i></button>
									</span>
								</div>
								&nbsp;&nbsp;<a title="高级搜索" href="javascript:void(0)" id="search_type" class="btn btn-white btn-bitbucket"><i class="fa fa-filter" style="color: #D8E3EF;"></i></a>
							</li>
						</ul>
						</form>
					</div>
				</div>
				<div class="row" style="margin: 0">
					<div class="ibox-content" style="padding:0px;">
						<div class="ibox-content clearfix" id="table_container" style="padding:0px;border: none;">
							<form id="form1" action="" method="Post" style="position:relative;"> 
								<div id="table_div" class="full-height-scroll" style="left:0px;top:0px;">
								<if condition="$list eq null">
									<include file="Public:nodata" />
								<else/>
									<table class="table table-hover table-striped table_thead_fixed" id="tab_Test3" style="background:#fff;margin-bottom:0px;">
										<tr id="childNodes_num" class="tabTh">
											<td style="max-width: 60px;width:74px;padding:0 10px 0 7px;">
												<div class="checkbox checkbox-primary">
													<input type="checkbox" class="check_all"/>
													<label for=""></label>
												</div>
											</td>
											<td>{:L('HEADLINE')}</td>
											<td>{:L('CREATOR_ROLE')}</td>
											<td>
												<if condition="$_GET['asc_order'] == 'update_time'">
													<a href="{:U('announcement/index','desc_order=update_time&'.$parameter)}">{:L('UPDATE TIME')}&nbsp;<img src="__PUBLIC__/img/arrow_up.png"></a>
												<elseif condition="$_GET['desc_order'] == 'update_time'"/>
													<a href="{:U('announcement/index','asc_order=update_time&'.$parameter)}">{:L('UPDATE TIME')}&nbsp;<img src="__PUBLIC__/img/arrow_down.png"></a>
												<else/>
													<a href="{:U('announcement/index','desc_order=update_time&'.$parameter)}">{:L('UPDATE TIME')}</a>
												</if>
											</td>
											<td>{:L('THE CURRENT STATE')}</td>
										</tr>
										<volist name="list" id="vo">
											<tr class="controls_tr">
												<td>
													<div class="checkbox checkbox-primary">
														<input name="announcement_id[]" class="check_list" type="checkbox" value="{$vo.announcement_id}"/>
														<label for=""></label>
													</div>
												</td>
												<td><a href="{:U('announcement/view','id='.$vo['announcement_id'])}">{$vo.title}</a></td>
												<td>
													<notempty name="vo.owner.user_name"><a class="role_info" rel="{$vo.owner.role_id}" href="javascript:void(0)">{$vo.owner.user_name}</a></notempty>
												</td>
												<td><notempty name="vo.update_time">{$vo.update_time|date="Y-m-d",###}<notempty></td>
												<td>
													<if condition="$vo['status'] eq '1'">
														<span class="fa fa-circle" style="color:#F5715F"></span>&nbsp;&nbsp;&nbsp;已发布
													<elseif condition="$vo['status'] eq '2'"/>
														<span class="fa fa-circle" style="color:#7CCA4E"></span>&nbsp;&nbsp;&nbsp;未发布
													</if> 
												</td>
											</tr> 
										</volist>
									</table>
								</if>
								</div>
								<div id="tfoot_div" class="clearfix">
									<tr>
										<div class="clearfix" id="tfoot_page">	
											<if condition="$fields_search">
												<span class="pull-left" style="margin-left:25px;margin-top:10px;">本次搜索结果<span style="color:#F8AC59"> {$count} </span>条数据<a href="{:U('announcement/index')}" class="btn" style="background:#fff;border:1px solid #ccc;margin-left:10px;color:#999;" id="clearnumber">清除搜索条件</a></span>
											</if>
											{$page}<include file="Public:listrows" />
										</div>
									</tr>
								</div>
							</form>
						</div>
					</div>
				</div>
    		</div>
        </div>
    </div>
</div>
<div style="display:none" id="dialog-field-search" title="高级搜索">
	<form class="form-inline" id="searchForm" action="" method="get">
		<div id="search_add" style="width:650px;float:left;">
		<empty name="fields_search">
			<div id="con_search_1" style="float:left;width:650px;margin:0 10px 0 10px;">
				<ul class="nav pull-left" style="margin:0px 0 0 23px;width:650px">
					<li class="pull-left">
						<select id="field_1" style="width:auto" class="form-control input-sm field_name new-select" onchange="changeCondition(1)" >
							<option class="" value="name">--请选择条件--</option>
							<option class="word" value="title">{:L('HEADLINE')}</option>
							<option class="word" value="content">{:L('CONTENT')}</option>
							<option class="role" value="role_id">{:L('AUTHORS')}</option>
							<option class="date" value="create_time">{:L('CREATE_TIME')}</option>
							<option class="date" value="update_time">更新时间</option>
						</select>&nbsp;&nbsp;
					</li>
					<li class="pull-left" id="conditionContent_1">
						<select id="condition_1" style="width:auto" class="form-control input-sm new-select" onchange="changeSearch()" name="name[condition]">
							<option value="contains">{:L('CONTAINS')}</option>
							<option value="is">{:L('IS')}</option>								
							<option value="start_with">{:L('START_WITH')}</option>
							<option value="end_with">{:L('END_WITH')}</option>
							<option value="is_empty">{:L('IS_EMPTY')}</option>
						</select>&nbsp;&nbsp;
					</li>
					<li class="pull-left" id="searchContent_1">
						<input id="search_1" type="text" style="width:160px;" class="input-medium form-control input-sm search-query" name="name[value]"/>&nbsp;&nbsp;
					</li>
				</ul>
			</div>
			<?php $max_key = 1;?>
		<else />
			<volist name="fields_search" key="key1" id="vo">
				<div id="con_search_{$key1}" style="float:left;width:650px;margin:0px 10px 0 10px;padding-top:10px;">
					<div id="rem_{$key1}" class="pull-left" style="line-height:30px;"><a href="javascript:void(0);" class="rem_search" rel="{$key1}" title="移除"><span class="fa fa fa-times-circle"></span></a></div>
					<ul class="nav pull-left" style="margin:0px 0 0 5px;width:620px;">
						<li class="pull-left">
							<select id="field_{$key1}" style="width:auto" class="form-control input-sm field_name new-select" onchange="changeCondition({$key1})" >
								<option class="" value="name">--请选择条件--</option>
								<option class="word" <if condition = "$vo['field'] eq 'title'">selected="selected"</if> value="title">{:L('HEADLINE')}</option>
								<option class="word" <if condition = "$vo['field'] eq 'content'">selected="selected"</if> value="content">{:L('CONTENT')}</option>
								<option class="role" <if condition = "$vo['field'] eq 'role_id'">selected="selected"</if> value="role_id">{:L('AUTHORS')}</option>
								<option class="date" <if condition = "$vo['field'] eq 'create_time'">selected="selected"</if> value="create_time">{:L('CREATE_TIME')}</option>
								<option class="date" <if condition = "$vo['field'] eq 'update_time'">selected="selected"</if> value="update_time">更新时间</option>
							</select>&nbsp;&nbsp;
						</li>
						<li class="pull-left" id="conditionContent_{$key1}">
						<if condition="$vo.form_type eq 'number'">
							<select id="condition" style="width:auto" class="form-control input-sm" name="{$vo['field']}[condition]">
								<option value="gt" <if condition="$_GET[$vo['field']][condition] eq 'gt'">selected="selected"</if>>{:L('GT')}</option>
								<option value="lt" <if condition="$_GET[$vo['field']][condition] eq 'lt'">selected="selected"</if>>{:L('LT')}</option>
								<option value="eq" <if condition="$_GET[$vo['field']][condition] eq 'eq'">selected="selected"</if>>{:L('EQ')}</option>
								<option value="neq" <if condition="$_GET[$vo['field']][condition] eq 'neq'">selected="selected"</if>>{:L('NEQ')}</option>
							</select>
						<elseif condition="$vo.field eq 'role_id' || $vo.form_type eq 'datetime'"/>
						<elseif condition="$vo.form_type eq 'box'" />
						<else />
							<select id="condition" style="width:auto" class="form-control input-sm" name="{$vo['field']}[condition]">
								<option value="contains" <if condition="$_GET[$vo['field']][condition] eq 'contains'">selected="selected"</if>>{:L('INCLUDE')}</option>
								<option value="not_contain" <if condition="$_GET[$vo['field']][condition] eq 'not_contain'">selected="selected"</if>>{:L('EXCLUSIVE')}</option>
								<option value="is" <if condition="$_GET[$vo['field']][condition] eq 'is'">selected="selected"</if>>{:L('YES')}</option>
								<option value="isnot" <if condition="$_GET[$vo['field']][condition] eq 'isnot'">selected="selected"</if>>{:L('NO')}</option>					
								<option value="start_with" <if condition="$_GET[$vo['field']][condition] eq 'start_with'">selected="selected"</if>>{:L('BEGINNING_CHARACTER')}</option>
								<option value="end_with" <if condition="$_GET[$vo['field']][condition] eq 'end_with'">selected="selected"</if>>{:L('TERMINATION_CHARACTER')}</option>
								<option value="is_empty" <if condition="$_GET[$vo['field']][condition] eq 'is_empty'">selected="selected"</if>>{:L('MANDATORY')}</option>
								<option value="is_not_empty" <if condition="$_GET[$vo['field']][condition] eq 'is_not_empty'">selected="selected"</if>>{:L('ISNOTEMPTY')}</option>
							</select>
						</if>
						</li>
						<li class="pull-left" id="searchContent_{$key1}" style="margin-left:5px;">
						<if condition="$vo.form_type neq 'box' && $vo.form_type neq 'address'">
							<if condition="$vo.form_type eq 'datetime'">
								<input id="start_{$vo['field']}" type="text" class="form-control input-sm search-query" name="{$vo['field']}[start]" onclick="WdatePicker()" value="{$fields_search[$vo['field']][start]}" rel="announcement"/> 至 <input id="end_{$vo['field']}" type="text" class="form-control input-sm search-query" name="{$vo['field']}[end]" onclick="WdatePicker()" value="{$fields_search[$vo['field']][end]}" rel="announcement"/>
							<elseif condition="$vo['field'] eq 'role_id'"/>
								<span id="owner_role_search" rel="{$key1}" rel1="{$vo['field']}[value]" rel2="{$_GET[$vo['field']][value]}"/>
								<script type="text/javascript">
									var key_id = $('#owner_role_search').attr('rel');
									var search_owner_role_id = $('#owner_role_search').attr('rel1');
									var owner_roleid = $('#owner_role_search').attr('rel2');
									$.ajax({
										type:'get',
										url:'index.php?m=user&a=getrolelist&module=announcement&action=index',
										async:false,
										success:function(data){
											options = '';
											$.each(data.data, function(k, v){
												options += '<option value="'+v.role_id+'" checkedit>'+v.user_name+' ['+v.department_name+'-'+v.role_name+'] </option>';
											});
											$("#searchContent_"+key_id+"").html('<select class="selectpicker show-tick form-control input-sm" data-live-search="true" id="search_'+key_id+'" name="'+search_owner_role_id+'" style="width:auto">' + options + '</select>');
											/*$('#search_'+key_id).selectpicker('val',owner_roleid);
											$('#search_'+key_id).selectpicker('refresh');*/
											var owner_roleid = "{$_GET[$vo['field']][value]}";
											$('#search_'+key_id+' option[value='+owner_roleid +']').prop('selected',true);
											
										},
										dataType:'json'
									});		
								</script>
							<else/>	
								<input name="{$vo['field']}[value]" type="text" class="form-control input-sm" class="{$vo['form_type']}" value="{$_GET[$vo['field']][value]}" rel="product">
							</if>
						</if>
						</li>
					</ul>
				</div>
				<?php $max_key = $key1;?>
			</volist>
		</empty>
		</div>
		<input type="hidden" name="content" <if condition="$_GET['content']">value="resource"</if> />
		<input type="hidden" name="this_page" value="{$this_page}" />
		<div class="clearfix"></div>
		<div style="margin-left: 35px;margin-top:10px;"><a href="javascript:void(0);" style="display: -moz-stack;margin: 30px 0px 0px; font-size: 12px; color: rgb(62, 133, 233);" id="add_btn">+添加筛选条件</a>
		</div>
		<div class="pull-right" class="button_type" style="margin:20px;"> 
			<input type="hidden" name="m" value="announcement"/>
			<input type="hidden" name="act" id="act" value="index"/>
			<if condition="$Think.get.by neq null">
				<input type="hidden" name="by" value="{$Think.get.by}"/>
			</if>
		</div>
	</form>
</div>
<div class="hide" id="dialog-role-info" title="{:L('DIALOG_USER_INFO')}">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div class="" style="display:none;" id="dialog-import" title="{:L('IMPORT DATA')}">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div class="" style="display:none;" id="dialog-role-info" title="{:L('DIALOG_USER_INFO')}">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<script type="text/javascript">
/*让复选框默认取消选择*/
$(':checkbox').prop('checked', false);
$("#return_check").click(function(){
	window.location.href="{:U('contract/revokeCheck', 'id=')}"+$(this).attr('rel');
});
$("#edit_contract").click(function(){
	window.location.href="{:U('announcement/edit','id=')}"+$(this).attr('rel');
});
$("#dialog-import").dialog({
	autoOpen: false,
	modal: true,
	width: 600,
	maxHeight: 400,
	position: ["center",100]
});
$("#short_search").val('{$Think.get.search}');

if ("{:C('isMobile')}" == "1") {
	width = $('.container').width() * 0.9;
} else {
	width = 800;
}

$("#dialog-role-info").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 550,
	position: ["center",100]
});
/*添加筛选条件*/
var m = {$max_key};
$('#add_btn').click(function(){
	m += 1;
	$('#search_add').append('<div id="con_search_'+m+'" style="float:left;width:650px;padding-top:10px;margin:0px 10px 0 10px;"><div  id="rem_'+m+'" class="pull-left" style="line-height:30px;"><a href="javascript:void(0);" class="rem_search" rel="'+m+'" title="移除"><span class="fa fa-times-circle"></span></a></div>&nbsp;<ul class="nav pull-left" style="margin:0px 0 0 5px;width:620px"><li class="pull-left"><select id="field_'+m+'"  style="width:auto" class="form-control input-sm field_name new-select" onchange="changeCondition('+m+')" name=""><option class="" value="name">--请选择条件--</option><option class="word" value="title">{:L('HEADLINE')}</option><option class="word" value="content">{:L('CONTENT')}</option><option class="role" value="role_id">{:L('AUTHORS')}</option><option class="date" value="create_time">{:L('CREATE_TIME')}</option><option class="date" value="update_time">{:L('UPDATE_TIME')}</option></select>&nbsp;&nbsp;</li><li class="pull-left" id="conditionContent_'+m+'"><select id="condition_'+m+'" style="width:auto" class="form-control input-sm new-select" name="condition" onchange="changeSearch()"><option value="contains">{:L('CONTAINS')}</option><option value="is">{:L('IS')}</option><option value="start_with">{:L('START_WITH')}</option><option value="end_with">{:L('END_WITH')}</option><option value="is_empty">{:L('IS_EMPTY')}</option></select>&nbsp;&nbsp;</li><li class="pull-left" id="searchContent_'+m+'"><input id="search_'+m+'" type="text" style="width:160px;" class="input-medium form-control input-sm search-query" name="search"/>&nbsp;&nbsp;</li></ul></div>');  
});
$(document).on('click','.rem_search',function(){
	var num = $(this).attr('rel');
	$('#con_search_'+num).remove();
});

// 筛选重复判断
var dosearch = 1;
function doh(){
	var ary = new Array();
	var field_name = '';
	var is_submit = 1;
	$('.field_name').each(function(k, v){
		field_name = $(this).find("option:selected").val();
		if(jQuery.inArray(field_name,ary) >= 0){
			is_submit = 0;
			swal({
				title: "筛选条件中有重复项！",
				text: data.info,
				type: "error"
			});
			dosearch = 0;
			return false;
		}
		ary[k] = field_name;
	})
	if(is_submit == 1){
		$("#searchForm").submit();
	}
}

$("#dialog-field-search").dialog({
	autoOpen: false,
	modal: true,
	width: 700,
	height: 500,
	position: ["center",100],
	buttons: {
		"确定": function () {
			doh();
			if(dosearch == 1){
				$(this).dialog("close");
			}
		},
		"取消": function () {
			$(this).dialog("close");
		}
	}
});
$("#search_type").click(function(){
	$("#dialog-field-search").dialog('open');
});

$(function(){
	$('#check_all').on('ifChecked', function(event){
		$("input[class='check_list']").iCheck('check');
	});
	$('#check_all').on('ifUnchecked', function(event){
		$("input[class='check_list']").iCheck('uncheck');
	});
	
	$('#delete').click(function(){
		var id_array = new Array();
		$("input.check_list:checked").each(function(){  
			id_array.push($(this).val());
		});
		if(id_array.length == 0){
			alert_crm('您没有选中任何公告！');
			return false;
		}
		swal({
			title: "您确定要删除公告信息吗？",
   			text: "删除后将无法恢复，请谨慎操作！",
			type: "warning",   
			showCancelButton: true,   
			confirmButtonColor: "#DD6B55",   
			confirmButtonText: "是的，我要删除！",
	        cancelButtonText:'让我再考虑一下…',
	        closeOnConfirm:false,
	        closeOnCancel:false
		},
		function(isConfirm){
	        if (isConfirm) {
	        	$.ajax({
		            type:'post',
		            url: "{:U('announcement/delete')}",
		            data: {announcement_id: id_array},
		            async: false,
		            success: function (data) {
						if (data.status == 1) {
							swal("删除成功！", "您已经永久删除了信息！", "success");
							location.reload();
						}else{
							swal({
								title: "操作失败！",
								text:data.info,
								type: "error"
							})
							return false;
						}
		            },
		            dataType: 'json'
		        });
	        } else {
	            swal("已取消","您取消了删除操作！","error");
	        }
	    });
	});

	$("#dosearch").click(function(){
		result = checkSearchForm();
		if(result){
			$("#act").val('search');$("#searchForm").submit();
		} 
	});
	$(".role_info").click(function(){
		$role_id = $(this).attr('rel');
		$('#dialog-role-info').dialog('open');
		$('#dialog-role-info').load('{:U("user/dialoginfo","id=")}'+$role_id);
	});
});
</script>
<include file="Public:footer" />	